<script>
    export let modalClass = "";
    export let backdropClass = "";
    export let showModal = false;
    export let title = "";
    export let onClose;
    function closeModal(event) {
      if (event.target === event.currentTarget) {
        onClose();
      }
    }
  </script>
  
  {#if showModal}
    <div class={backdropClass} on:click={closeModal} >
    <div class={modalClass}>
      <header>
        <h2>{title}</h2>
        <button on:click={onClose}>×</button>
      </header>
      <slot />
    </div>
    </div>
  {/if}
  <style scoped>
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.5);
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }
  
    .modal-content {
      background-color: white;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      width: 80%;
      max-width: 500px;
      text-align: center;
    }
  
    header {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  
    header button {
      background: none;
      border: none;
      font-size: 1.5em;
      cursor: pointer;
    }
  </style>
  